Skip to content

feat(trace): record how a trace session was run - #3444

Merged
jiparis merged 1 commit into
chainloop-dev:mainfrom
jiparis:jiparis/pfm-7321-differentiate-trace-modes
Sep 15, 2026
Merged

jiparis merged 1 commit into
chainloop-dev:mainfrom
jiparis:jiparis/pfm-7321-differentiate-trace-modes

Conversation

@jiparis

@jiparis jiparis commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

chainloop trace hooks and chainloop trace run both emit a CHAINLOOP_AI_CODING_SESSION material with an identical shape, so an ongoing coding session and a one-shot wrapped command cannot be told apart once attested.

This PR adds a new session.mode field to the AI coding session payload, with the following values:

  • coding for a session traced through the git hooks installed by trace init
  • generic for a single-shot chainloop trace run

An absent mode means coding, so sessions recorded before this change keep their meaning. The mode is also published as the chainloop.material.aisession.mode material annotation, which is an exact key/value match consumers can filter on without downloading and parsing the session itself.

The field is a plain string rather than a closed enumeration, so further modes (spec, security) need no schema version bump. It is added to the redaction deny-list alongside the other identifiers and enumerations the secret scanner must never rewrite.

Ingesting the mode into the platform database and defaulting the AI coding dashboards to mode = "coding" is separate follow-up work.


AI disclosure: this contribution was assisted by Claude Code.

Review in cubic

`chainloop trace init` and `chainloop trace run` both produce a
CHAINLOOP_AI_CODING_SESSION material with an identical shape, so an
ongoing coding session and a one-shot wrapped command are
indistinguishable once attested.

Add session.mode to the AI coding session payload: "coding" for the
git-hook path installed by trace init, "generic" for trace run. An
absent mode means "coding", so sessions recorded before this change
keep their meaning. The mode is also published as the
chainloop.material.aisession.mode annotation, which is an exact
key/value match consumers can filter on without downloading and
parsing the session itself.

The field is a plain string rather than a closed enumeration so that
further modes need no schema version bump.

Assisted-by: Claude Code
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>

Chainloop-Trace-Sessions: 79f9ea21-3bbd-4ee9-8640-097df91d751c
@chainloop-platform

chainloop-platform Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

AI Session Checks — 🟡 60% · ⚠️ 1 failing

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟡 60% 1 ⚠️ 1 100% AI / 0% Human 12 +246 / -4 4h14m31s

🟡 60% — 100% AI — ⚠️ 1 policies failing

Sep 15, 2026 16:48 UTC · 4h14m31s · $28.70 · 586 in / 110.7k out · claude-code 2.1.272 (claude-opus-5)

View session details ↗

Change Summary

  • Adds session.mode plus coding/generic handling for AI coding session payloads.
  • Publishes chainloop.material.aisession.mode and protects it from redaction.
  • Threads mode through the CLI trace entry points and expands schema/material tests around the new behavior.

AI Session Overall Score

🟡 60% — Well-planned, well-tested work, but the final PR-creation request was not completed.

AI Session Analysis Breakdown

🟢 94% · context-and-planning

🟢 A written plan and user-approved design choices preceded implementation. · High Impact

🟢 93% · scope-discipline

🟢 The recorded diff stayed within the intended producer-side files and tests. · High Impact

🟢 92% · user-trust-signal

No notes.

🟢 90% · solution-quality

🟢 The AI used red-to-green test loops instead of papering over failures. · High Impact

🟢 84% · verification

🟡 The live control-plane path was not exercised because the local stack was unavailable. · Low Severity

🔴 35% · alignment

🔴 After create a PR, the session shows commit/push steps but no PR creation. · High Severity

💡 When the ask is to create a PR, show the PR URL or the command that opened it before stopping.


File Attribution

████████████████████ 100% AI / 0% Human

Status Attribution File Lines
modified ai pkg/attestation/crafter/materials/chainloop_ai_coding_session_test.go +71 / -0
modified ai internal/schemavalidators/schemavalidators_test.go +63 / -0
created ai pkg/attestation/crafter/materials/aicodingsession/mode_test.go +43 / -0
modified ai pkg/attestation/crafter/materials/aicodingsession/aicodingsession.go +27 / -2
modified ai app/cli/pkg/action/trace_hook_handler.go +17 / -1
modified ai pkg/attestation/crafter/materials/chainloop_ai_coding_session.go +13 / -1
modified ai internal/schemavalidators/internal_schemas/aicodingsession/ai-coding-session-0.1.schema.json +4 / -0
modified ai app/cli/cmd/trace_hook.go +2 / -0
modified ai app/cli/pkg/action/trace_run.go +2 / -0
modified ai pkg/attestation/crafter/materials/aicodingsession/redact_test.go +2 / -0
modified ai pkg/attestation/crafter/materials/aicodingsession/redact.go +1 / -0
modified ai pkg/attestation/crafter/materials/aicodingsession/testdata/session-with-secrets.json +1 / -0

Policies (4, 1 failing)

Status Policy Material Messages
✅ Passed ai-config-ai-agents-allowed ai-coding-session-79f9ea -
✅ Passed ai-config-no-dangerous-commands ai-coding-session-79f9ea -
⚠️ Failed ai-config-no-secrets ai-coding-session-79f9ea Secret (aws-access-token) detected in session content [turn=682, source=tool_result, line=93]: assert.Contains(t, string(got), "[REDACTED:aws-access-token]")
✅ Passed ai-config-mcp-servers-allowed ai-coding-session-79f9ea -

Security Checks — ✅ 9 passing

✅ secret-scan

Status Policy Messages
✅ Passed secrets-detection -

✅ sast-scan

Status Policy Messages
✅ Passed sast -
✅ Passed cwe-top25 -
✅ Passed cwe-top26-40-cusp -
✅ Passed owasp-top10-2025 -

✅ iac-scan

Status Policy Messages
✅ Passed iac-misconfiguration -

PR info

Status Policy Messages
✅ Passed pr-min-approvals -
✅ Passed pr-description-required -
✅ Passed pr-user-story-linked -

⏭️ 2 scans not applied

Scan Reason
vulnerability-scan no manifest/lockfile changed
github-actions-scan no workflow files changed

View attestation ↗


Powered by Chainloop and Chainloop Trace

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 12 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread app/cli/pkg/action/trace_run.go
@jiparis
jiparis requested a review from a team September 15, 2026 21:34
@jiparis
jiparis merged commit 3b7599d into chainloop-dev:main Sep 15, 2026
16 of 17 checks passed
@jiparis
jiparis deleted the jiparis/pfm-7321-differentiate-trace-modes branch September 15, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants